| Conditions | 5 |
| Total Lines | 29 |
| Code Lines | 25 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import {Inject} from '@nestjs/common'; |
||
| 17 | |||
| 18 | public convert(holiday: Holiday): void { |
||
| 19 | const user = holiday.getUser(); |
||
| 20 | const type = |
||
| 21 | holiday.getLeaveType() === HolidayLeaveType.MEDICAL |
||
| 22 | ? EventType.MEDICAL_LEAVE |
||
| 23 | : EventType.HOLIDAY; |
||
| 24 | |||
| 25 | const dates = this.dateUtils.getWorkedDaysDuringAPeriod( |
||
| 26 | new Date(holiday.getStartDate()), |
||
| 27 | new Date(holiday.getEndDate()) |
||
| 28 | ); |
||
| 29 | |||
| 30 | if (!dates) { |
||
| 31 | return; |
||
| 32 | } |
||
| 33 | |||
| 34 | const firstDate = dates[0].toISOString(); |
||
| 35 | const lastDate = dates[dates.length - 1].toISOString(); |
||
| 36 | |||
| 37 | for (const date of dates) { |
||
| 38 | const currentDate = date.toISOString(); |
||
| 39 | const time = |
||
| 40 | (firstDate === currentDate && false === holiday.isStartsAllDay()) || |
||
| 41 | (lastDate === currentDate && false === holiday.isEndsAllDay()) |
||
| 42 | ? 50 |
||
| 43 | : 100; |
||
| 44 | |||
| 45 | this.eventRepository.save(new Event(type, user, time, currentDate)); |
||
| 46 | } |
||
| 49 |